Backport: fix flymake margin indicator fallback logic
authorSpencer Baugh <sbaugh@janestreet.com>
Thu, 17 Apr 2025 20:22:08 +0000 (16:22 -0400)
committerEli Zaretskii <eliz@gnu.org>
Sat, 19 Apr 2025 14:37:40 +0000 (17:37 +0300)
Backport 861e7f8b60e4bf076bf5991d25a22b3a012746bd to fix bug#77313, so
that fringe indicators are once again reliably the default on frames
that support them.

Do not merge to master.

* lisp/progmodes/flymake.el (flymake-indicator-type)
(flymake-mode): Fix margin fallback behavior.

lisp/progmodes/flymake.el

index f8a294908ba3fede61a422d48309c2844a375a64..a9e15fbbb126549909ebb46a7369ee30830621a3 100644 (file)
@@ -185,22 +185,23 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'."
                 (const right-fringe)
                 (const :tag "No fringe indicators" nil)))
 
-(defcustom flymake-indicator-type (if (display-graphic-p)
-                                      'fringes
-                                    'margins)
+(defcustom flymake-indicator-type 'fringes
   "Indicate which indicator type to use for display errors.
 
 The value can be nil (don't indicate errors but just highlight them),
-fringes (use fringes) or margins (use margins)
+the symbol `fringes' (use fringes) or the symbol `margins' (use
+margins).
 
 Difference between fringes and margin is that fringes support displaying
 bitmaps on graphical displays and margins display text in a blank area
 from current buffer that works in both graphical and text displays.
+Thus, even when `fringes' is selected, margins will still be used on
+text displays and also when fringes are disabled.
 
 See Info node `Fringes' and Info node `(elisp)Display Margins'."
-  :version "30.1"
+  :version "30.2"
   :type '(choice (const :tag "Use Fringes" fringes)
-                 (const :tag "Use Margins "margins)
+                 (const :tag "Use Marginsmargins)
                  (const :tag "No indicators" nil)))
 
 (defcustom flymake-margin-indicators-string
@@ -1393,6 +1394,13 @@ special *Flymake log* buffer."  :group 'flymake :lighter
     (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
     (add-hook 'eldoc-documentation-functions 'flymake-eldoc-function t t)
 
+    (when (and (eq flymake-indicator-type 'fringes)
+               (not (cl-case flymake-fringe-indicator-position
+                      (left-fringe (< 0 (nth 0 (window-fringes))))
+                      (right-fringe (< 0 (nth 1 (window-fringes)))))))
+      ;; There are no fringes in the buffer, fallback to margins.
+      (setq-local flymake-indicator-type 'margins))
+
     ;; AutoResize margins.
     (flymake--resize-margins)